package com.zgl.gemduel.model;

import com.zgl.gemduel.service.RoomResourceNotificationService;
import lombok.Data;

@Data
public class Reward {

    private RewardType rewardType; // 奖励类型
    private String description;    // 奖励描述

    // 构造函数
    public Reward() {}
    
    public Reward(RewardType rewardType, String description) {
        this.rewardType = rewardType;
        this.description = description;
    }
    
    // 根据奖励类型执行相应的处理逻辑
    public void processReward(RoomResourceNotificationService notificationService, String roomId, String playerIp) {
        switch (this.rewardType) {
            case TAKE_GEM:
                processTakeGem(notificationService, roomId, playerIp);
                break;
            case EXTRA_TURN:
                processExtraTurn(notificationService, roomId, playerIp);
                break;
            case CHANGE_COLOR:
                processChangeColor(notificationService, roomId, playerIp);
                break;
            case GAIN_PRIVILEGE:
                processGainPrivilege(notificationService, roomId, playerIp);
                break;
            case TAKE_GEM_FROM_OPPONENT:
                processTakeGemFromOpponent(notificationService, roomId, playerIp);
                break;
            default:
                // 未知奖励类型，可以记录日志或抛出异常
                break;
        }
    }
    
    // 取宝石奖励的处理逻辑
    private void processTakeGem(RoomResourceNotificationService notificationService, String roomId, String playerIp) {
        // TODO: 实现取宝石的具体逻辑
        // 示例：从房间资源中获取宝石并分配给玩家
        System.out.println("Processing TAKE_GEM reward for room: " + roomId + ", player IP: " + playerIp);
        notificationService.notifyRoomCommand(roomId, "reward_take_gem");
        // 具体实现待补充
    }
    
    // 再来一轮奖励的处理逻辑
    private void processExtraTurn(RoomResourceNotificationService notificationService, String roomId, String playerIp) {
        // TODO: 实现再来一轮的具体逻辑
        // 示例：更新游戏状态，给予玩家额外回合
        System.out.println("Processing EXTRA_TURN reward for room: " + roomId + ", player IP: " + playerIp);
        notificationService.notifyRoomCommand(roomId, "reward_extra_turn");
        // 具体实现待补充
    }
    
    // 变色奖励的处理逻辑
    private void processChangeColor(RoomResourceNotificationService notificationService, String roomId, String playerIp) {
        // TODO: 实现实现变色的具体逻辑
        // 示例：允许玩家改变某个宝石的颜色
        System.out.println("Processing CHANGE_COLOR reward for room: " + roomId + ", player IP: " + playerIp);
        notificationService.notifyRoomCommand(roomId, "reward_change_color");
        // 具体实现待补充
    }

    // 获得特权奖励的处理逻辑
    private void processGainPrivilege(RoomResourceNotificationService notificationService, String roomId, String playerIp) {
        notificationService.notifyRoomCommand(roomId, "reward_gain_privilege");
    }

    // 拿取对手宝石奖励的处理逻辑
    private void processTakeGemFromOpponent(RoomResourceNotificationService notificationService, String roomId, String playerIp) {
        notificationService.notifyRoomCommand(roomId, "reward_take_gem_from_opponent");
    }
}